package com.org.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.org.pojo.ServeRespond;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName: ServeRespondMapper
 * Package: com.org.mapper
 * Description:
 *
 * @Author Origin
 * @Create 2024/2/15 21:55
 * @Version 1.0
 */
@Mapper
public interface ServeRespondMapper extends BaseMapper<ServeRespond> {

    @Insert("insert into serve_respond(serve_id, user_id, state, create_time) values(#{serveId}, #{userId}, '已选择', now())")
    void add(Integer serveId, Integer userId);

    @Update("update serve_respond set state=#{state} where id=#{serveRespondId}")
    void updateState(Integer serveRespondId, String state);

    @Select("select * from serve_respond where id = #{serveRespondId}")
    ServeRespond findById(Integer serveRespondId);


    @Select("select * from serve_respond where serve_id = #{id} and state <> '已撤销'")
    List<ServeRespond> list(Integer id);
}
